﻿using FluentAssertions;
using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;
using Xunit;

namespace Sustainalytics.Auth.Service.Tests
{
    [Trait("Category", "Unit")]
    public class Get_token_should : IClassFixture<TokenServer>
    {
        private readonly TokenServer tokenServer;

        public Get_token_should(TokenServer tokenServer)
        {
            this.tokenServer = tokenServer;
        }

        [Fact]
        public async Task return_bad_request_when_grant_type_is_not_client_credentials()
        {
            var content = new Dictionary<string, string>
            {
                { "grant_type", "invalid grant_type" }
            };

            var response = await tokenServer.GetResponseAsync(content);

            response.StatusCode.Should().Be(HttpStatusCode.BadRequest);
        }
    }
}
